﻿@model CustomerForumSubscriptionsModel
@using Nop.Web;
@using Nop.Web.Extensions;
@using Nop.Web.Framework;
@using Nop.Web.Models.Customer;
@{    
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    Html.AddTitleParts(T("PageTitle.ForumSubscriptions").Text);
}
@section left
{
    @Html.Partial("MyAccountNavigation", Model.NavigationModel, new ViewDataDictionary())
}
<div class="account-page">
    <div class="page-title">
        <h1>@T("Account.MyAccount") - @T("Account.ForumSubscriptions")</h1>
    </div>
    <div class="clear">
    </div>
    <div class="body">
        @if (Model.ForumSubscriptions.Count > 0)
        {
            @T("Account.ForumSubscriptions.Description")
            <br />
            <br />
            <script type="text/javascript">
                $(document).ready(function () {

                    $('#selectall').click(function () {
                        $('.forum-subscriptions-box .rowcheckbox').attr('checked', $(this).is(':checked')).change();
                    });

                    $('.forum-subscriptions-box .rowcheckbox').live('change', function (e) {
                        var numChkBoxes = $('.forum-subscriptions-box .rowcheckbox').length;
                        var numChkBoxesChecked = $('.forum-subscriptions-box .rowcheckbox:checked').length;
                        $('#selectall').attr('checked', numChkBoxes == numChkBoxesChecked && numChkBoxes > 0);
                    });
                });
            </script>
            using (Html.BeginRouteForm("CustomerForumSubscriptions", FormMethod.Post))
            {
            <div class="forum-subscriptions-box">
                <table class="data-table">
                    <col width="1" />
                    <col />
                    <thead>
                        <tr>
                            <th class="a-center">
                                <input type="checkbox" id="selectall" />
                            </th>
                            <th class="a-center">
                                @T("Account.ForumSubscriptions.InfoColumn")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @for (int i = 0; i < Model.ForumSubscriptions.Count; i++)
                        {
                            var item = Model.ForumSubscriptions[i];
                            <tr @(i % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
                                <td class="a-center">
                                    <input type="checkbox" name="fs@(item.Id)" class="rowcheckbox" />
                                </td>
                                <td class="a-left">
                                    @if (item.TopicSubscription)
                                    {
                                        @Html.RouteLink(item.Title, "TopicSlug", new { Id = item.ForumTopicId, slug = item.Slug })
                                    }
                                    else
                                    {
                                        @Html.RouteLink(item.Title, "ForumSlug", new { Id = item.ForumId, slug = item.Slug })
                                    }
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                @if (Model.PagerModel.TotalPages > 1)
                {
                    <div class="fsgridpagerstyle">
                        @Html.Pager(Model.PagerModel)
                    </div>
                }
                <div class="clear">
                </div>
                <div class="buttons">
                    <input type="submit" value="@T("Account.ForumSubscriptions.DeleteSelected")" class="deleteselectedfsbutton" />
                </div>
            </div>
            }
        }
        else
        {
            @T("Account.ForumSubscriptions.NoSubscriptions")
        }
    </div>
</div>
